package com.learn.rabbitmq.quickstart;

import com.rabbitmq.client.ConnectionFactory;

/**
 * @author wangxing
 * @version 2020/8/13 22:19 Administrator
 */
public class RabbitmqUtils {
    private static final String RABBITMQ_HOST = "192.168.1.150";
    private static final String RABBITMQ_PASSWORD = "mall";
    private static final String RABBITMQ_USERNAME = "mall";
    private static final String RABBITMQ_VIRTUAL_HOST = "/mall";
    private static final Integer RABBITMQ_PORT = 5672;
    private static final Integer TIMEOUT = 1000 * 60;
    private static ConnectionFactory connectionFactory = new ConnectionFactory();

    static {
        connectionFactory.setHost(RABBITMQ_HOST);
        connectionFactory.setPort(RABBITMQ_PORT);
        connectionFactory.setVirtualHost(RABBITMQ_VIRTUAL_HOST);
        connectionFactory.setUsername(RABBITMQ_USERNAME);
        connectionFactory.setPassword(RABBITMQ_PASSWORD);
        connectionFactory.setConnectionTimeout(TIMEOUT);
    }

    /**
     * 获取连接工厂
     * @return ConnectionFactory
     */
    public static ConnectionFactory getConnectionFactory(){return connectionFactory;};
}
